/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.bo;

import org.ipti.br.tag.dao.QuestResultFacade;
import org.ipti.br.tag.entity.QuestResult;
import java.util.Calendar;
import javax.inject.Inject;
import java.util.List;
import javax.ejb.Stateless;

/**
 *
 * @author ipti
 */
@Stateless
public class QuestResultBO {

    @Inject
    private QuestResultFacade questResultDAO;

    public QuestResultFacade getQuestResultDAO() {
        return questResultDAO;
    }

    public void create(QuestResult questResult) {
        getQuestResultDAO().create(questResult);
    }

    public void edit(QuestResult questResult) {
        getQuestResultDAO().edit(questResult);
    }

    public void remove(QuestResult questResult) {
        getQuestResultDAO().remove(questResult);
    }

    public QuestResult find(Object id) {
        return getQuestResultDAO().find(id);
    }

    public List<QuestResult> findAll() {
        return getQuestResultDAO().findAll();
    }

    public void editForSynchronization(QuestResult questResult) {
        getQuestResultDAO().editForSynchronization(questResult);
    }

    public boolean dateAlreadyExists(Calendar date, Long questionID) {
        boolean exists = false;
        List<QuestResult> questResults = getQuestResultDAO().findQuestResultsPerQuestion(questionID);
        for (QuestResult qr : questResults) {
            if (qr.getData().toString().equals(date.toString())) {
                exists = true;
                break;
            }
        }
        return exists;
    }

    public QuestResult findQuestResultPerPersonAskDate(Long personID, Long askID, Calendar date) {
        return getQuestResultDAO().findQuestResultPerPersonAskDate(personID, askID, date);
    }

    public List<QuestResult> modifiedQuestResultBetweenDate(Calendar initialDate, Calendar finalDate, Long serialNumber) {
        return getQuestResultDAO().modifiedQuestResultBetweenDate(initialDate, finalDate, serialNumber);
    }
}
